package org.lucas.controller;

import lombok.extern.slf4j.Slf4j;
import org.lucas.service.PhoneLocationQueryService;
import org.lucas.utils.Result;
import org.lucas.vo.PhoneLocationApiResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/phone")
public class PhoneLocationQueryController {

    @Autowired
    private PhoneLocationQueryService phoneLocationQueryService;

    @GetMapping("/queryLocation/{phoneNumber}")
    public Result queryLocation(@PathVariable Long phoneNumber) {
        PhoneLocationApiResponseVO phoneLocationApiResponseVO = phoneLocationQueryService.queryLocation(phoneNumber);

        log.info("查询结果：{}", phoneLocationApiResponseVO);
        if(phoneLocationApiResponseVO.getCode() == 200){
            return Result.success(phoneLocationApiResponseVO);
        }else{
            return Result.error(phoneLocationApiResponseVO.getMsg());
        }

    }

}
